<%@ page import="com.as.utils.RandomUtils" %>
<%@ page import="java.util.Properties" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<%
    Properties pps = new Properties();
    pps.load(this.getClass().getClassLoader().getResourceAsStream("server.properties"));

    String qid = RandomUtils.getRandomString(5);
    String serverUrl = "ws://" + pps.getProperty("server_ip") + "/login/" + qid;
    System.out.println("serverUrl: " + serverUrl);
%>
<!DOCTYPE html>
<html>
<head>
    <title>AS登录</title>
    <script>
        var websocket = null;
        //判断当前浏览器是否支持WebSocket
        if ('WebSocket' in window) {
            websocket = new WebSocket("<%= serverUrl%>");
        }
        else {
            alert('当前浏览器 Not support websocket');
        }
        //接收到消息的回调方法
        websocket.onmessage = function (event) {
            document.getElementById('message').innerHTML += event.data + '<br/>';
            window.location.href = "http://www.thronbirds.party";
        };
    </script>
    <script type="text/javascript" src="js/web_socket.js"></script>
</head>
<body style="text-align: center;">
<div id="message"></div>
<h1>学生出勤管理系统</h1>
<img src="/QRCode?qid=<%= qid%>">
<p>使用手机扫码登录，或<a href="login_by_id.html">点此</a>用账号密码登录</p>
</body>

</html>